home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byte0987.arc
/
REUSESOF.ARC
/
SORTELEM.DEF
< prev
next >
Wrap
Text File
|
1986-07-15
|
2KB
|
52 lines
DEFINITION MODULE SortElemType;
(* This module is intended to describe the elements to be sorted
* as an abstract data type.
*)
EXPORT QUALIFIED ElemType, compare, select, optionMenu,
ReadArray, WriteArray;
TYPE
ElemType; (* pointer to data element *)
PROCEDURE compare (x, y: ElemType): BOOLEAN;
(* compare(x,y) implements: x < y
defined as NOT (y <= x), for ascending order;
and if descending order is desired
compare(x,y) should implement: x > y
defined as NOT (x <= y);
where "<=" denotes a binary relation that must satisfy
the total order properties:
1. x <= x
2. x <= y AND y <= x ==> x = y
3. x <= y AND y <= z ==> x <= z
4. x <= y OR y <= x for every x, y
*)
PROCEDURE select (option: CARDINAL);
(* input: - a number denoting the requested option
output: - the exported compare procedure gets assigned to one
of the comparison procedures.
- the option should be valid, otherwise a default
may be used
*)
PROCEDURE optionMenu;
(* output: - displays on the screen the available options. *)
PROCEDURE ReadArray(VAR A: ARRAY OF ElemType): CARDINAL;
(* input: - an array of pointers, declared by the user module.
output: - the array is filled with pointers to the memory used
by the elements read, and the number of them is
returned.
errors: - can run out of memory.
NOTE: if the file contains more elements than those which
can be stored in the array, they are ignored.
*)
PROCEDURE WriteArray(A: ARRAY OF ElemType; n: CARDINAL) ;
(* input: - an array of pointers, and the number of elements.
output: - the elements are written to current output of InOut.
*)
END SortElemType.